package visao;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import Modelo.musica;
import controle.ControleMusica;

public class Musica extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JButton btnSelecionar;
	private JLabel lblNewLabel;
	private JLabel lblNome;
	private ControleMusica controle;
	private JButton btnBuscar;
	private JButton bntExcluir;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Musica frame = new Musica();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Musica() {
		controle = new ControleMusica();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 284);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNomeMusico = new JLabel("Cadastro Musico");
		lblNomeMusico.setBounds(10, 11, 92, 14);
		contentPane.add(lblNomeMusico);
		
		textField = new JTextField();
		textField.setBounds(10, 72, 223, 20);
		contentPane.add(textField);
		textField.setColumns(10);
		
		lblNome = new JLabel("Nome");
		lblNome.setBounds(10, 47, 46, 14);
		contentPane.add(lblNome);
		
		lblNewLabel = new JLabel("Tempo Faixa");
		lblNewLabel.setBounds(10, 113, 62, 14);
		contentPane.add(lblNewLabel);
		
		textField_1 = new JTextField();
		textField_1.setBounds(10, 140, 223, 20);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
		
		btnSelecionar = new JButton("Concluir");
		btnSelecionar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				musica m = new musica();
				m.setNome(textField.getText());
				m.setTempoFaixa(Double.parseDouble(textField_1.getText()));
				controle.salvar(m);
			}
		});
		btnSelecionar.setBounds(24, 190, 117, 41);
		contentPane.add(btnSelecionar);
		
		btnBuscar = new JButton("Buscar");
		btnBuscar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				musica m = new musica();
				m.setNome(textField.getText());
				m.setTempoFaixa(Double.parseDouble(textField_1.getText()));
				controle.salvar(m);
			}	
		});
		btnBuscar.setBounds(171, 190, 111, 41);
		contentPane.add(btnBuscar);
		
		bntExcluir = new JButton("Excluir");
		bntExcluir.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				musica m = new musica();
				m.setNome(textField.getText());
				m.setTempoFaixa(Double.parseDouble(textField_1.getText()));
				controle.salvar(m);
			}
			
		});
		bntExcluir.setBounds(314, 190, 118, 41);
		contentPane.add(bntExcluir);
	}
}
